﻿package mortal.game.view.wizard
{
    import Message.DB.Tables.*;
    import Message.Public.*;
    import __AS3__.vec.*;
    import flash.utils.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.wizard.data.*;

    public class WizardCache extends Object
    {
        public var gost:int;
        public var combat:int;
        public var combatArr:Array;
        private var _fightWizardCode:int;
        private var _soulList:Vector.<WizardData>;
        private var _equipConfigInfoDic:Dictionary;

        public function WizardCache()
        {
            this._equipConfigInfoDic = new Dictionary();
            return;
        }// end function

        public function get soulList() : Vector.<WizardData>
        {
            var _loc_1:String = null;
            if (this._soulList == null)
            {
                this._soulList = new Vector.<WizardData>;
                for (_loc_1 in WizardConfig.instance.wizardUpArr)
                {
                    
                    this._soulList.push(new WizardData(int(_loc_1)));
                }
            }
            return this._soulList;
        }// end function

        public function getCurWizardSkillIdByOldSkillId(param1:int) : int
        {
            var _loc_4:WizardData = null;
            var _loc_5:int = 0;
            var _loc_6:TSkill = null;
            if (this._soulList == null)
            {
                return -1;
            }
            var _loc_2:* = SkillConfig.instance.getInfoById(param1);
            var _loc_3:int = 0;
            while (_loc_3 < this._soulList.length)
            {
                
                _loc_4 = this._soulList[_loc_3];
                if (!_loc_4.isHasWizard)
                {
                }
                else
                {
                    _loc_5 = _loc_4.tSpriteEx.xpskillId;
                    _loc_6 = SkillConfig.instance.getInfoById(_loc_5);
                    if (_loc_6.name == _loc_2.name)
                    {
                        return _loc_5;
                    }
                }
                _loc_3++;
            }
            return -1;
        }// end function

        public function set soulList(param1:Vector.<WizardData>) : void
        {
            this._soulList = param1;
            return;
        }// end function

        public function updateList(param1:Array) : Vector.<WizardData>
        {
            var _loc_2:SpriteInfo = null;
            for each (_loc_2 in param1)
            {
                
                (this.soulList[(_loc_2.SpriteCode - 1)] as WizardData).spriteInfo = _loc_2;
                if (_loc_2.state)
                {
                    this.fightWizardCode = _loc_2.SpriteCode;
                }
            }
            return this.soulList;
        }// end function

        public function updateSoul(param1:SpriteInfo) : void
        {
            this.soulList[(param1.SpriteCode - 1)].spriteInfo = param1;
            if (param1.state)
            {
                this.fightWizardCode = param1.SpriteCode;
            }
            return;
        }// end function

        public function set fightWizardCode(param1:int) : void
        {
            this._fightWizardCode = param1;
            return;
        }// end function

        public function get fightWizardCode() : int
        {
            return this._fightWizardCode;
        }// end function

        public function get fightWizardData() : WizardData
        {
            if (this.fightWizardCode == 0)
            {
                return null;
            }
            return this.soulList[(this.fightWizardCode - 1)];
        }// end function

        public function get XpSkillId() : int
        {
            if (this.fightWizardData && this.fightWizardData.isHasWizard)
            {
                return this.fightWizardData.tSpriteEx.xpskillId;
            }
            return 0;
        }// end function

        public function getWizardEquipConfigInfo(param1:ItemData) : ItemEquipInfo
        {
            var _loc_2:ItemEquipInfo = null;
            var _loc_3:* = param1.itemInfo.category + "-" + param1.itemInfo.type + "-" + param1.itemInfo.level;
            _loc_2 = this._equipConfigInfoDic[_loc_3] as ItemEquipInfo;
            if (_loc_2 == null)
            {
                _loc_2 = ItemConfig.instance.getWizardEquipByLevel(param1.itemInfo.category, param1.itemInfo.type, param1.itemInfo.level, 0);
                this._equipConfigInfoDic[_loc_3] = _loc_2;
            }
            return _loc_2;
        }// end function

        public function getWizardDataByCode(param1:int) : WizardData
        {
            return this.soulList[(param1 - 1)];
        }// end function

    }
}
